/*
      ::: ::: :::             ::: :::             :::
     :+: :+:   :+:           :+:   :+:           :+:
    +:+ +:+     +:+         +:+     +:+         +:+
   +#+ +#+       +#+       +#+       +#+       +#+
  +#+ +#+         +#+     +#+         +#+     +#+
 #+# #+#           #+#   #+#           #+#   #+#
### ###             ### ###             ### ###

| AHOY WORLD |

PilotCheck.sqf was created by Kamaradski [AW] ~ Tweaked by Tactical_Force[AWG] for Admin Vehicles Check
You may alter, use or change this code as you wish as long as you keep the original authors name in it.

*/
private ["_v","_unitname"];														// set _v for this client only (private)

AdminVehicles = ["A_LB","HELLCAT"];

while {true} do {
	waitUntil {sleep 0.5; alive player};									// wait till player is alive
	if !(getPlayerUID player in evo_admins) then { 
		while {alive player} do	{											// as long as player is alive
			waitUntil {sleep 0.5; vehicle player != player};				// wait till player enters a vehicle
			avehname = typeOf vehicle player;							// Get vehicle classname of current vehicle
			_v = vehicle player;											// SET _v as the vehicle the player is in
			_unitname = vehicleVarName _v;
			_seats = [driver _v];
			_seats = _seats + [_v turretUnit [0]]; //Co-Pilot
			_seats = _seats + [_v turretUnit [1]]; //Left Gun
			_seats = _seats + [_v turretUnit [2]]; //Right Gun
			if (_unitname in AdminVehicles)  then {					// if the vehicle is in the dis-allowed list
				if (player in _seats) then {								// if player is driver of that vehicle
					player action ["eject", _v];							// eject player
					waitUntil {sleep 0.5; vehicle player == player};		// wait till player is booted out of the vehicle
					player action ["engineOff", _v];				// message on screen
				};			// turn off the engine of the vehicle
					hintSilent "Only Admins can use this vehicle!";
			};
		};
	} else {																// if player is not pilot
		waitUntil {sleep 0.5; !alive player};								// Wait till player is alive
	};
	Sleep 0.5;
};